using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ItmPListMap : EntityTypeConfiguration<ItmPList>
    {
        public ItmPListMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Item_id)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("ItmPList");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Item_id).HasColumnName("Item_id");
            this.Property(t => t.Plist_id).HasColumnName("Plist_id");
            this.Property(t => t.Price).HasColumnName("Price");
            this.Property(t => t.K).HasColumnName("K");
            this.Property(t => t.ARE).HasColumnName("ARE");
            this.Property(t => t.OR).HasColumnName("OR");
            this.Property(t => t.L).HasColumnName("L");
            this.Property(t => t.R).HasColumnName("R");
            this.Property(t => t.A).HasColumnName("A");
            this.Property(t => t.N).HasColumnName("N");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.HOSPITAL).HasColumnName("HOSPITAL");
            this.Property(t => t.CONSULTATION).HasColumnName("CONSULTATION");
            this.Property(t => t.Patdue1).HasColumnName("Patdue1");
            this.Property(t => t.Patdue2).HasColumnName("Patdue2");
            this.Property(t => t.Hospital1).HasColumnName("Hospital1");
            this.Property(t => t.Hospital2).HasColumnName("Hospital2");
            this.Property(t => t.App).HasColumnName("App");
            this.Property(t => t.K2).HasColumnName("K2");
            this.Property(t => t.ARE2).HasColumnName("ARE2");

            // Relationships
            this.HasRequired(t => t.Item)
                .WithMany(t => t.ItmPLists)
                .HasForeignKey(d => d.Item_id);
            this.HasRequired(t => t.PriceLst)
                .WithMany(t => t.ItmPLists)
                .HasForeignKey(d => d.Plist_id);

        }
    }
}
